package com.partners.model;

import com.github.pagehelper.Page;
import lombok.Getter;
import lombok.Setter;

import java.util.List;

/**
 * @author liangyongle
 * @date 2018/7/19 0019
 */
@Getter
@Setter
public class PagingResult<T> {

    private Object total;

    private List<T> list;

    public static<T> PagingResult<T> create(List<T> list) {
        PagingResult<T> result = new PagingResult();
        if( list instanceof Page) {
            Page page = (Page) list;
            result.setTotal(page.getTotal());
        } else {
            result.setTotal(list.size());
        }

        result.setList(list);
        return result;

    }

}
